package flc.ast;

import android.view.View;

import androidx.annotation.NonNull;

import java.util.ArrayList;
import java.util.List;

import flc.ast.databinding.ActivityHomeBinding;
import flc.ast.fragment.ConstructFragment;
import flc.ast.fragment.MyFragment;
import flc.ast.fragment.TemplateFragment;
import flc.ast.fragment.GuessFragment;
import flc.ast.fragment.HomeFragment;
import stark.common.basic.base.BaseTabFragmentHomeActivity;
import stark.common.basic.event.EventStatConstant;
import stark.common.basic.event.EventStatProxy;

public class HomeActivity extends BaseTabFragmentHomeActivity<ActivityHomeBinding> implements View.OnClickListener {

    @Override
    protected int getPageType() {
        return EventStatConstant.PAGE_TAB_HOME;
    }

    @Override
    protected void initView() {
        super.initView();
        EventStatProxy.getInstance().statLaunch(this);
    }

    @NonNull
    @Override
    protected List<BaseTabFragmentHomeActivity<ActivityHomeBinding>.FragmentViewBinder> getFragmentViewBinders() {
        List<FragmentViewBinder> listFragment=new ArrayList<>();
        listFragment.add(new FragmentViewBinder(HomeFragment.class,R.id.llHome));
        listFragment.add(new FragmentViewBinder(GuessFragment.class,R.id.llGuess));
        listFragment.add(new FragmentViewBinder(TemplateFragment.class,R.id.llDressUp));
        listFragment.add(new FragmentViewBinder(ConstructFragment.class,R.id.llConstruct));
        listFragment.add(new FragmentViewBinder(MyFragment.class,R.id.llMy));
        return listFragment;
    }

    @Override
    protected void onFragmentViewClick(View view) {
        clearSelection();
        switch (view.getId()){
            case R.id.llHome:
                mDataBinding.ivHome.setImageResource(R.drawable.adongmjes);
                break;
            case R.id.llGuess:
                mDataBinding.ivGuess.setImageResource(R.drawable.acaidm);
                break;
            case R.id.llDressUp:
                mDataBinding.ivDressUp.setImageResource(R.drawable.ahuanzhuang);
                break;
            case R.id.llConstruct:
                mDataBinding.ivConstruct.setImageResource(R.drawable.agoujian);
                break;
            case R.id.llMy:
                mDataBinding.ivMy.setImageResource(R.drawable.awod);
                break;
        }
    }

    @Override
    protected int getFragmentContainerId() {
        return R.id.flHome;
    }

    @Override
    protected int onCreate() {
        return R.layout.activity_home;
    }

    private void clearSelection() {
        mDataBinding.ivHome.setImageResource(R.drawable.asy);
        mDataBinding.ivGuess.setImageResource(R.drawable.acdm);
        mDataBinding.ivDressUp.setImageResource(R.drawable.ahz);
        mDataBinding.ivConstruct.setImageResource(R.drawable.apt);
        mDataBinding.ivMy.setImageResource(R.drawable.awd);
    }

}